package com.android.rapidcash.activitys

import android.content.Intent
import android.os.Bundle
import android.os.CountDownTimer
import com.android.lib.base.baseclass.BaseVMActivity
import com.android.lib.base.manager.MMKVManager
import com.android.rapidcash.MainActivity
import com.android.rapidcash.utils.CommUtils
import com.android.rapidcash.viewmodel.MainViewModel
import com.blankj.utilcode.util.BarUtils
import com.rapidcash.abanca.santander.vivus.revolut.waylet.libertex.icmarkets.caixabank.databinding.ActivitySplashBinding


class SplashScreenActivity : BaseVMActivity<MainViewModel, ActivitySplashBinding>() {

    override fun initView(savedInstanceState: Bundle?) {
    }

    override fun initData() {

        /**
         * CountDownTimer timer = new CountDownTimer(3000, 1000)中，
         * 第一个参数表示总时间，第二个参数表示间隔时间。
         * 意思就是每隔一秒会回调一次方法onTick，然后1秒之后会回调onFinish方法。
         */
        val timer = object : CountDownTimer(3000, 1000) {
            override fun onTick(millisUntilFinished: Long) {}

            override fun onFinish() {
                if (MMKVManager.decodeBoolean("first", true)) {
                    startActivity(Intent(this@SplashScreenActivity, PermissionActivity::class.java))
                } else {
                    startActivity(Intent(this@SplashScreenActivity, MainActivity::class.java))
                }


                MMKVManager.encodeBoolean("first", false)
                finish()
            }

        }
        timer.start()
    }

}